package cn.lf.controller;


import cn.lf.dto.sys.file.FileDelDTO;
import cn.lf.dto.sys.file.FileUploadDTO;
import cn.lf.dto.sys.file.FileUploadRepDTO;
import cn.lf.dto.sys.file.FileUploadReqDTO;
import cn.lf.service.IFileInfoService;
import cn.lf.utils.ResponseModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 文件信息 前端控制器
 * </p>
 *
 * @author guoyy
 * @since 2024-04-11
 */
@RestController
@RequestMapping("/file-info")
@Api(tags = "文件接口")
public class FileInfoController {

    @Autowired
    private IFileInfoService fileInfoService;

    @PostMapping("uploadFile")
    @ApiOperation("上传文件")
    public ResponseModel<FileUploadRepDTO> uploadFile(FileUploadReqDTO fileUploadReqDTO){

        FileUploadRepDTO result = fileInfoService.uploadFile(fileUploadReqDTO);

        return ResponseModel.buildSuccessResult(result);
    }

    @PostMapping("uploadFileUnParam")
    @ApiOperation("上传文件 没有其他参数")
    public ResponseModel<FileUploadRepDTO> uploadFileUnParam(FileUploadDTO fileUploadDTO){

        FileUploadRepDTO result = fileInfoService.uploadFileUnParam(fileUploadDTO);

        return ResponseModel.buildSuccessResult(result);
    }

    @PostMapping("delFile")
    @ApiOperation("删除文件")
    public ResponseModel delFile(@RequestBody FileDelDTO fileDelDTO){

        fileInfoService.delFile(fileDelDTO);

        return ResponseModel.buildSuccessResult();
    }

}
